Skip to content

Introduce get metric label utility#6234

Open
apata wants to merge 1 commit intomasterfrom
refactor-to-get-metrics-labels
Open

Introduce get metric label utility#6234
apata wants to merge 1 commit intomasterfrom
refactor-to-get-metrics-labels

Conversation

@apata
Copy link
Copy Markdown
Contributor

@apata apata commented Apr 7, 2026

Changes

Introduces get metric label utility. Needed for refactoring main graph. Useful when sunsetting Metrics class.

Tests

  • Automated tests have been added

Changelog

  • This PR does not make a user-facing change

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@apata apata requested a review from a team April 7, 2026 17:55
Comment on lines +3 to +6
export const getMetricLabel = (
metric: Metric,
{ hasConversionGoalFilter }: { hasConversionGoalFilter: boolean }
): string => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature works for replacing Top Stats, but with breakdowns in mind, I would like to propose:

type MetricLabelOverrides = {
  default: Record<Metric, string>,
  conversionGoalFilter: Record<Metric, string>,
  realtime: Record<Metric, string>
}

export const getMetricLabel = (
  metric: Metric,
  dashboardState: DashboardState,
  // Not sure what's best for MetricLabelOverrides:
  // * an object like {default: Record<Metric, string>, conversionGoalFilter: Record<Metric, string>, realtime: ...}
  // OR
  // * a function (metric, dashboardState) => string
  overrides: MetricLabelOverrides
): string => {...}

Here are a few reasons why:

  • In most goal-filtered breakdown reports, Unique conversions is just Conversions
  • In entry/exit pages reports, visits are labelled Total entrances/exits
  • In the conversions (goals breakdown) report, visitors is labelled Uniques
  • ...

Not saying this should be a part of this PR, but perhaps passing dashboardState instead of {hasConversionGoalFilter} could be a better starting point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants